Skip to content

Run a trained model on an image ​

The inferencer node runs a model you trained in the platform on the images that reach it, on the controller itself, and adds its predictions to the message. In this guide you run a segmentation model that finds the biscuits of a pack, and read what it answers.

What you will learn

  • How to choose one of your models in the inferencer node
  • How to see the predictions drawn on the image
  • How to read the predictions in the message

Before you start

You need a trained model in your project and a flow that brings images. Here the flow brings images of the «DemoCookies» dataset with a from-dataset node: see Send dataset images through a flow.

1. Add an inferencer node ​

Type inferencer in «filter nodes» and drag the node after the one that brings the images, then wire them together.

Add an inferencer node

2. Connect it to your project ​

Double-click the node. «Input field» is where it finds the image, msg.image here, and «Output field» where it leaves the predictions, msg.inference. In «Firebase», choose the connection to your project, «Rosepetal Firebase»: the models you trained in the platform join the list of models.

Connect it to your project

3. Choose the model ​

Leave «Model source» on «Manual» and choose the model in «Model Name». A ✔ marks the models already on the controller; any other is downloaded from your project the first time. Next to each name you see its task and its architecture.

Choose the model

4. Draw the predictions on the image ​

Open «Debug Image» and tick «Show debug image». The node then draws its predictions on each image and shows it under the node: boxes for detection, filled shapes for segmentation, the tag for classification.

Draw the predictions on the image

5. Show the predictions in the debug panel ​

Click «Done». Add a debug node after the inferencer, open it and set «Output» to msg.inference, so that the debug panel shows the predictions.

6. Deploy and run the model ​

Click «Deploy». The controller loads the model and warms it up, which takes a few seconds: wait until the node says «Ready», then press the button of the inject node. Under the inferencer you see the image with the biscuits it found, and how long it took.

Deploy and run the model

7. Read the predictions ​

Expand the message in the debug panel. msg.inference is a list with one entry per object found. Each one holds:

  • tag: what the object is, one of the tags of the dataset the model learned from;
  • confidence: how sure the model is, from 0 to 1;
  • polygons: the outline of the object, for segmentation, and area, the part of the image it covers;
  • raw_boxes and the other box formats: the box around the object.

All positions go from 0 to 1, as a fraction of the width and the height of the image, so they hold whatever the size of the image. How long each step took is in msg.performance.

Read the predictions

Good to know ​

  • A model per node. Each inferencer node keeps its model loaded on the controller's GPU while the node exists, even when no image arrives. Delete or disable the inferencer nodes you no longer use.
  • Dynamic. With «Model source» on «Dynamic», the node takes the name of the model from the message (msg.modelName by default), and downloads it from your project if the controller does not have it yet. A panel that lets the operator switch models works this way.
  • Advanced config. The second tab holds the settings of the model, such as the minimum confidence or the size the image is resized to before it goes into the model.

Next steps ​

Recorded on Rosepetal release 1.8.15, Node-RED 5.0.10.